package com.gitee.wsl.service

import com.gitee.wsl.service.task.AbstractRetryAbleTask
import com.gitee.wsl.service.task.listener.AbstractTaskListener
import com.gitee.wsl.service.task.scope.ResourceTaskScope
import com.gitee.wsl.service.task.RetryAbleTask
import com.gitee.wsl.service.task.TaskStatus


object Download {
    lateinit var downloadService: DownloadService

    fun init(_downloadService: DownloadService){
        downloadService =_downloadService
    }
}

interface DownloadScope: ResourceTaskScope {

   val downloadUrl:String

   val progressPoint:Int

   fun connectAble():Boolean

}

interface DownLoadTask: RetryAbleTask<DownloadScope, TaskStatus>, DownloadScope {

}

abstract class AbstractDownLoadTask(adapter: AbstractTaskListener<DownloadScope>?=null): AbstractRetryAbleTask<DownloadScope, TaskStatus>(
    TaskStatus.UNKNOWN,adapter), DownLoadTask {
    override fun getTaskScope(): DownloadScope {
        return this
    }
}

interface DownloadService: TaskServer<DownloadScope> {

    fun isDownLoaded(url:String):Boolean

    fun getDownLoadState(url:String): TaskStatus

    fun startDownLoad(url:String): DownLoadTask

    fun startDimeDownLoad(url:String)

    fun getDownLoad(url:String): DownLoadTask

    fun stopDownLoad(url:String)

    fun removeDownLoad(url:String)
}

abstract class AbstractDownLoadService:
    AbstractTaskService<DownLoadTask, DownloadScope, TaskStatus>(), DownloadService {

}


